package controle;

import java.io.IOException;
import java.io.ObjectOutputStream;
import java.net.Socket;
import java.net.UnknownHostException;

public class ServidorBroadcastWorker extends Thread {
	
	private MensagemServidorBroadcast	mensagem;
	private String						ip;
	
	public ServidorBroadcastWorker(MensagemServidorBroadcast mensagem, String ip)
	{
		this.mensagem	=	mensagem;
		this.ip			=	ip;
	}

	public void run()
	{
		Socket socket;
		try
		{
			System.out.println("EH o IP do peste: " + this.ip);
			socket = new Socket(this.ip, SocketControlConstants.portaServidorClienteBroadcast);
			ObjectOutputStream	msg	=	new ObjectOutputStream(socket.getOutputStream());
			
			msg.writeObject(this.mensagem);
			socket.close();
		}
		catch(UnknownHostException e)
		{
			e.printStackTrace();
		}
		catch(IOException e)
		{
			e.printStackTrace();
		}
	}
}
